package com.sumainfor.pc.gmio.service.impl;

import com.sumainfor.common.Constants;
import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.ComUtils;
import com.sumainfor.common.utlis.ParamsCommon;
import com.sumainfor.pc.gmio.dao.*;
import com.sumainfor.pc.gmio.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.pc.gmio.feign.Zfeign.ZzuulFeign;
import com.sumainfor.pc.gmio.service.HoGasMeterService;
import com.sumainfor.pc.gmio.service.HoSurveyTopicService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.*;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 问卷调查
 */
@Service
public class HoSurveyTopicSerivceImpl implements HoSurveyTopicService {

    private ReentrantLock lock = new ReentrantLock(false);
    Logger log = LoggerFactory.getLogger(HoSurveyTopicSerivceImpl.class);
    @Autowired
    private HoSurveyTopicMapper hoSurveyTopicMapper;
    @Autowired
    private HoSurveyContentMapper hoSurveyContentMapper;
    /**
     * 查询问卷列表
     */
    public List<Map<String,Object>> getHoSurveyTopicList(Map<String, Object> params){
        //查询账单问题
        List<Map<String,Object>> topicList=hoSurveyTopicMapper.getHoSurveyTopicList(params);
        //查询账单问题选项
        List<Map<String,Object>> contentList=hoSurveyContentMapper.getHoSurveyContentList(params);
        for (Map<String,Object> topicmap : topicList){
            List<Map<String,Object>> list=new ArrayList<Map<String, Object>>();
            for (Map<String,Object> contentmap : contentList) {
                if (MapUtils.getString(topicmap, "SurId").equals(MapUtils.getString(contentmap, "SurId"))) {
                    list.add(contentmap);
                }
            }
            topicmap.put("contentList",list);
        }
        return topicList;
    }
}
